﻿using System;
using System.Collections.Generic;

namespace CustomControlPractice.Controls.DateSlotPicker
{
    public class Resource
    {
        public string Name { get; set; }
        public Dictionary<DateRange, int> AvailableCount { get; set; }
    }

    [Serializable]
    public class DateRange
    {
        private readonly DateTime startDate;
        private readonly DateTime endDate;

        public DateRange(DateTime startDate,DateTime endDate)
        {
            this.startDate = startDate;
            this.endDate = endDate;
        }

        public DateTime StartDate
        {
            get { return startDate; }
        }
        public DateTime EndDate
        {
            get { return endDate; }
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != typeof (DateRange)) return false;
            return Equals((DateRange) obj);
        }

        public bool Equals(DateRange other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return other.startDate.Equals(startDate) && other.endDate.Equals(endDate);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                return (startDate.GetHashCode()*397) ^ endDate.GetHashCode();
            }
        }
    }
}